import { http } from './request.js';

// 商品相关API
export const productApi = {
    // 获取商品列表
    getProducts(params) {
        return http.get('/user/products', params);
    },

    // 获取商品列表（分页）
    getProductList(params) {
        return http.get('/user/products/page', params);
    },

    // 获取商品详情
    getProductById(id) {
        return http.get(`/user/products/${id}`);
    },

    // 根据分类获取商品
    getProductsByCategory(categoryId, params) {
        return http.get(`/user/products/by-category/${categoryId}`, params);
    },

    // 根据店铺获取商品
    getProductsByStore(storeId, params) {
        return http.get(`/user/products/store/${storeId}`, params);
    },

    // 搜索商品
    searchProducts(keyword, params) {
        return http.get('/user/products/search', { keyword, ...params });
    },

    // 获取热门商品
    getPopularProducts(limit = 10, storeId) {
        return http.get('/user/products/popular', { limit, storeId });
    },

    // 获取新品推荐
    getNewProducts(limit = 10, storeId) {
        return http.get('/user/products/new', { limit, storeId });
    },

    // 获取商品SKU
    getProductSkus(productId) {
        return http.get(`/user/products/${productId}/skus`);
    },

    // 获取商品SPU
    getProductSpus(params) {
        return http.get('/user/product-spus', params);
    },

    // 获取商品SPU详情
    getProductSpuById(id) {
        return http.get(`/user/product-spus/${id}`);
    },

    // 获取商品标签
    getProductTags(productId) {
        return http.get(`/user/products/${productId}/tags`);
    },

    // 获取热门标签
    getPopularTags(limit = 10) {
        return http.get('/user/product-tags/popular', { limit });
    },

    // 根据标签获取商品
    getProductsByTag(tagId, params) {
        return http.get(`/user/products/tag/${tagId}`, params);
    }
}; 